package com.hangim.pce.common.search.enums;

/**
 * ElasticSearch动作类型
 */
public enum ESActionType {
    DEFAULT("default", "默认动作类型"),
    SYNC("sync", "同步"),
    REMOVE("remove", "删除");

    // 动作类型
    private final String code;
    // 描述
    private final String desc;

    ESActionType(final String code, final String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ESActionType getESActionType(String code) {
        ESActionType[] ts = ESActionType.values();
        for (ESActionType t : ts) {
            if (t.getCode().equalsIgnoreCase(code)) {
                return t;
            }
        }
        return DEFAULT;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
